<style type="text/css">
    .sm-st {
        background: #fff;
        padding: 20px;
        -webkit-border-radius: 3px;
        -moz-border-radius: 3px;
        border-radius: 3px;
        margin-bottom: 20px;
    }

    .sm-st-icon {
        width: 60px;
        height: 60px;
        display: inline-block;
        line-height: 60px;
        text-align: center;
        font-size: 30px;
        background: #eee;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        float: left;
        margin-right: 10px;
        color: #fff;
    }

    .sm-st-info {
        padding-top: 2px;
    }

    .sm-st-info span {
        display: block;
        font-size: 24px;
        font-weight: 600;
    }

    .orange {
        background: #fa8564 !important;
    }

    .tar {
        background: #45cf95 !important;
    }

    .sm-st .green {
        background: #86ba41 !important;
    }

    .pink {
        background: #AC75F0 !important;
    }

    .yellow-b {
        background: #fdd752 !important;
    }

    .stat-elem {

        background-color: #fff;
        padding: 18px;
        border-radius: 40px;

    }

    .stat-info {
        text-align: center;
        background-color: #fff;
        border-radius: 5px;
        margin-top: -5px;
        padding: 8px;
        -webkit-box-shadow: 0 1px 0px rgba(0, 0, 0, 0.05);
        box-shadow: 0 1px 0px rgba(0, 0, 0, 0.05);
        font-style: italic;
    }

    .stat-icon {
        text-align: center;
        margin-bottom: 5px;
    }

    .st-red {
        background-color: #F05050;
    }

    .st-green {
        background-color: #27C24C;
    }

    .st-violet {
        background-color: #7266ba;
    }

    .st-blue {
        background-color: #23b7e5;
    }

    .stats .stat-icon {
        color: #28bb9c;
        display: inline-block;
        font-size: 26px;
        text-align: center;
        vertical-align: middle;
        width: 50px;
        float: left;
    }

    .stat {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: inline-block;
    }

    .stat .value {
        font-size: 20px;
        line-height: 24px;
        overflow: hidden;
        text-overflow: ellipsis;
        font-weight: 500;
    }

    .stat .name {
        overflow: hidden;
        text-overflow: ellipsis;
        margin: 5px 0;
    }

    .stat.lg .value {
        font-size: 26px;
        line-height: 28px;
    }

    .stat-col {
        margin:0 0 10px 0;
    }
    .stat.lg .name {
        font-size: 16px;
    }

    .stat-col .progress {
        height: 2px;
    }

    .stat-col .progress-bar {
        line-height: 2px;
        height: 2px;
    }

    .item {
        padding: 30px 0;
    }


    #statistics .panel {
        min-height: 150px;
    }

    #statistics .panel h5 {
        font-size: 14px;
    }
</style>
<div class="panel panel-default panel-intro">
    <div class="panel-heading">
        {:build_heading(null, false)}
        <ul class="nav nav-tabs">
            <li class="active"><a href="#one" data-toggle="tab">{:__('Dashboard')}</a></li>
            <li><a href="#two" data-toggle="tab">{:__('Custom')}</a></li>
        </ul>
    </div>
    <div class="panel-body">
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade active in" id="one">

                <div class="row">
                    <div class="col-sm-3 col-xs-6">
                        <div class="sm-st clearfix">
                            <span class="sm-st-icon st-red"><i class="fa fa-users"></i></span>
                            <div class="sm-st-info">
                                <span>{$totaluser}</span>
                                {:__('Total user')}
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-3 col-xs-6">
                        <div class="sm-st clearfix">
                            <span class="sm-st-icon st-violet"><i class="fa fa-magic"></i></span>
                            <div class="sm-st-info">
                                <span>{$totaladdon}</span>
                                {:__('Total addon')}
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-3 col-xs-6">
                        <div class="sm-st clearfix">
                            <span class="sm-st-icon st-blue"><i class="fa fa-leaf"></i></span>
                            <div class="sm-st-info">
                                <span>{$attachmentnums}</span>
                                {:__('Total attachment')}
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-3 col-xs-6">
                        <div class="sm-st clearfix">
                            <span class="sm-st-icon st-green"><i class="fa fa-user"></i></span>
                            <div class="sm-st-info">
                                <span>{$totaladmin}</span>
                                {:__('Total admin')}
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-lg-8">
                        工单趋势
                        <input type="text" class="searchTime datetimepicker datetimepickerY" style="border-color: #d2d6de;border: 1px solid #ccc;" placeholder="开始日" name="start_time" id="start_time" value="{$workstartTime}">
                        <input type="text" class="searchTime datetimepicker datetimepickerY1" style="border-color: #d2d6de;border: 1px solid #ccc;" placeholder="截止日" name="end_time" id="end_time" value="{$workendTime}">
                        <select name="product" id = "product" lay-filter="aihao" style="border-color: #d2d6de;border: 1px solid #ccc;height: 26px;padding: 3px 6px;">
                            <option value="0">请选择产品</option>
                            {foreach name="product_list" item="vo"}
                            <option value="{$vo.id}" {if $product_id == $vo.id}selected{/if}>{$vo.name}</option>
                            {/foreach}
                        </select>
                        <button class="btn btn-success"  onclick="timeSearch()">查询</button>
                        <div id="echart" class="btn-refresh" style="height:300px;width:90%;margin-top: 10px"></div><br/>
                        工单占比
                        <!--<input type="text" class="searchTime datetimepicker datetimepickerY" placeholder="开始日" name="start_time" id="gcstart_time" value="{$gcworkstartTime}">
                        <input type="text" class="searchTime datetimepicker datetimepickerY1" placeholder="截止日" name="end_time" id="gcend_time" value="{$gcworkendTime}">
                        <button class="btn-success"  onclick="gctimeSearch()">查询</button>-->
                        {foreach name="gc_list" item="vo"}
                        <div style="text-align: center; vertical-align: middle; ">{$vo.title}</div>
                        <div class="chart tab-pane" id="pie-chart-{$key}" style="position: relative; height: 300px;width:100%;"></div><br/>
                        {/foreach}
                        多次维修工单占比
                        <input type="text" class="searchTime datetimepicker datetimepickerY" style="border-color: #d2d6de;border: 1px solid #ccc;" placeholder="开始日" name="start_time" id="gctwostart_time" value="{$gctwoworkstartTime}">
                        <input type="text" class="searchTime datetimepicker datetimepickerY1" style="border-color: #d2d6de;border: 1px solid #ccc;" placeholder="截止日" name="end_time" id="gctwoend_time" value="{$gctwoworkendTime}">
                        <button class="btn btn-success"  onclick="gctwotimeSearch()">查询</button>
                        <div class="chart tab-pane" id="pie-chart-two" style="position: relative; height: 300px;width:100%;"></div><br/>
                        知识库
                        <div id="echart-now" class="btn-refresh" style="height:300px;width:90%;"></div>
                    </div>

                    <div class="col-lg-4">
                        <div class="card sameheight-item stats">
                            <div class="card-block">
                                <div class="row row-sm stats-container">
                                    <div class="col-xs-6 stat-col">
                                        <div class="stat-icon"><i class="fa fa-rocket"></i></div>
                                        <div class="stat">
                                            <div class="value"> {$todayusersignup}</div>
                                            <div class="name"> {:__('Today user signup')}</div>
                                        </div>
                                        <div class="progress">
                                            <div class="progress-bar progress-bar-success" style="width: 20%"></div>
                                        </div>
                                    </div>
                                    <div class="col-xs-6 stat-col">
                                        <div class="stat-icon"><i class="fa fa-vcard"></i></div>
                                        <div class="stat">
                                            <div class="value"> {$todayuserlogin}</div>
                                            <div class="name"> {:__('Today user login')}</div>
                                        </div>
                                        <div class="progress">
                                            <div class="progress-bar progress-bar-success" style="width: 20%"></div>
                                        </div>
                                    </div>
                                    <div class="col-xs-6  stat-col">
                                        <div class="stat-icon"><i class="fa fa-calendar"></i></div>
                                        <div class="stat">
                                            <div class="value"> {$threednu}</div>
                                            <div class="name"> {:__('Three dnu')}</div>
                                        </div>
                                        <div class="progress">
                                            <div class="progress-bar progress-bar-success" style="width: 20%"></div>
                                        </div>
                                    </div>
                                    <div class="col-xs-6 stat-col">
                                        <div class="stat-icon"><i class="fa fa-calendar-plus-o"></i></div>
                                        <div class="stat">
                                            <div class="value"> {$sevendnu}</div>
                                            <div class="name"> {:__('Seven dnu')}</div>
                                        </div>
                                        <div class="progress">
                                            <div class="progress-bar progress-bar-success" style="width: 20%"></div>
                                        </div>
                                    </div>
                                    <div class="col-xs-6  stat-col">
                                        <div class="stat-icon"><i class="fa fa-user-circle"></i></div>
                                        <div class="stat">
                                            <div class="value"> {$sevendau}</div>
                                            <div class="name"> {:__('Seven dau')}</div>
                                        </div>
                                        <div class="progress">
                                            <div class="progress-bar progress-bar-success" style="width: 20%"></div>
                                        </div>
                                    </div>
                                    <div class="col-xs-6  stat-col">
                                        <div class="stat-icon"><i class="fa fa-user-circle-o"></i></div>
                                        <div class="stat">
                                            <div class="value"> {$thirtydau}</div>
                                            <div class="name"> {:__('Thirty dau')}</div>
                                        </div>
                                        <div class="progress">
                                            <div class="progress-bar progress-bar-success" style="width: 20%"></div>
                                        </div>
                                    </div>
                                    <div class="col-xs-6  stat-col">
                                        <div class="stat-icon"><i class="fa fa-user-circle"></i></div>
                                        <div class="stat">
                                            <div class="value"> {$worktodaysum}</div>
                                            <div class="name"> {:__('今日提交')}</div>
                                        </div>
                                        <div class="progress">
                                            <div class="progress-bar progress-bar-success" style="width: 20%"></div>
                                        </div>
                                    </div>
                                    <div class="col-xs-6  stat-col">
                                        <div class="stat-icon"><i class="fa fa-user-circle-o"></i></div>
                                        <div class="stat">
                                            <div class="value"> {$worknotsum}</div>
                                            <div class="name"> {:__('未完成工单')}</div>
                                        </div>
                                        <div class="progress">
                                            <div class="progress-bar progress-bar-success" style="width: 20%"></div>
                                        </div>
                                    </div>
                                    <div class="col-xs-6  stat-col">
                                        <div class="stat-icon"><i class="fa fa-user-circle-o"></i></div>
                                        <div class="stat">
                                            <div class="value"> {$workmsum}</div>
                                            <div class="name"> {:__('本周已完成')}</div>
                                        </div>
                                        <div class="progress">
                                            <div class="progress-bar progress-bar-success" style="width: 20%"></div>
                                        </div>
                                    </div>
                                    <div class="col-xs-6  stat-col">
                                        <div class="stat-icon"><i class="fa fa-user-circle-o"></i></div>
                                        <div class="stat">
                                            <div class="value"> {$shenhe_jin_t}</div>
                                            <div class="name"> {:__('今日审核平均时长')}</div>
                                        </div>
                                        <div class="progress">
                                            <div class="progress-bar progress-bar-success" style="width: 20%"></div>
                                        </div>
                                    </div>
                                    <div class="col-xs-6  stat-col">
                                        <div class="stat-icon"><i class="fa fa-user-circle-o"></i></div>
                                        <div class="stat">
                                            <div class="value"> {$bili}%</div>
                                            <div class="name"> {:__('较昨日提升')}</div>
                                        </div>
                                        <div class="progress">
                                            <div class="progress-bar progress-bar-success" style="width: 20%"></div>
                                        </div>
                                    </div>
                                    <div class="col-xs-6  stat-col">
                                        <div class="stat-icon"><i class="fa fa-user-circle-o"></i></div>
                                        <div class="stat">
                                            <div class="value"> {$gc_time_t}</div>
                                            <div class="name"> {:__('工厂处理平均时长')}</div>
                                        </div>
                                        <div class="progress">
                                            <div class="progress-bar progress-bar-success" style="width: 20%"></div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-6  stat-col" style="width:100%">
                                    <!--<div class="layui-form-item">

                                        <div class="layui-input-block">
                                            <select id="mySelect" name="select" lay-filter="aihao">
                                                <option value="0">三天内</option>
                                                <option value="1">七天内</option>
                                            </select>
                                        </div>
                                    </div>-->
                                    <input type="text" class="searchTime datetimepicker datetimepickerY" style="border-color: #d2d6de;border: 1px solid #ccc;width: 110px;" placeholder="开始日" name="gcpaihangstart_time" id="gcpaihangstart_time" value="">
                                    <input type="text" class="searchTime datetimepicker datetimepickerY1" style="border-color: #d2d6de;border: 1px solid #ccc;width: 110px;"  placeholder="截止日" name="gcpaihangend_time" id="gcpaihangend_time" value="">
                                    <button class="btn  btn-success"  onclick="gcpaihang()">查询</button>
                                    <a href="javascript:;" class="btn btn-info btn-export-log {:$auth->check('work/export')?'':'hide'}"  title="{:__('导出')}"><i class="fa fa-download"></i> {:__('导出')}</a>
                                    <table   class="table table-striped table-bordered table-hover table-nowrap" id="table_from"  style="width: 100%;margin-top:10px;">
                                        <thead>
                                        <tr>
                                            <th>工厂名称</th>
                                            <th>三天内</th>
                                            <th>七天内</th>
                                        </tr>
                                        </thead>

                                        <tbody class="lyj_tbody">
                                        </tbody>
                                    </table>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="tab-pane fade" id="two">
                <div class="row">
                    <div class="col-xs-12">
                        {:__('Custom zone')}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="path/to/your/datetimepicker.js"></script>
<script>
    function timeSearch() {
        var product  = $("#product").val();
        //alert(product);return;
        var startTime = $('#start_time').val();
        var endTime = $('#end_time').val();
        if(startTime=='' || endTime==''){
          //  alert('请选择正确的查询时间')
          //  return;
        }else{
            startTime =  Date.parse(startTime);
            endTime =  Date.parse(endTime);
            if(startTime>endTime){
                alert('开始时间不能大于结束时间')
                return;
            }
        }

        //window.top.location.href = 'dashboard/index?startTime='+startTime+"&endTime="+endTime;
        Fast.api.addtabs('dashboard/index?workstartTime='+startTime+"&workendTime="+endTime+"&product_id="+product, '控制台');

    }
    function gctimeSearch() {
        var startTime = $('#gcstart_time').val();
        var endTime = $('#gcend_time').val();
        if(startTime=='' || endTime==''){
          //  alert('请选择正确的查询时间')
           // return;
        }else{
            startTime =  Date.parse(startTime);
            endTime =  Date.parse(endTime);
            if(startTime>endTime){
                alert('开始时间不能大于结束时间')
                return;
            }
        }
        //window.top.location.href = 'dashboard/index?startTime='+startTime+"&endTime="+endTime;
        Fast.api.addtabs('dashboard/index?gcworkstartTime='+startTime+"&gcworkendTime="+endTime, '控制台');

    }
    function gctwotimeSearch() {
        var startTime = $('#gctwostart_time').val();
        var endTime = $('#gctwoend_time').val();
        if(startTime=='' || endTime==''){
           // alert('请选择正确的查询时间')
           // return;
        }else{
            startTime =  Date.parse(startTime);
            endTime =  Date.parse(endTime);
            if(startTime>endTime){
                alert('开始时间不能大于结束时间')
                return;
            }
        }
        //window.top.location.href = 'dashboard/index?startTime='+startTime+"&endTime="+endTime;
        Fast.api.addtabs('dashboard/index?gctwoworkstartTime='+startTime+"&gctwoworkendTime="+endTime, '控制台');

    }
    function gcpaihangdc(){
        var startTime = $('#gcpaihangstart_time').val();
        var endTime = $('#gcpaihangend_time').val();
        if(startTime=='' || endTime==''){
            // alert('请选择正确的查询时间')
            // return;
        }else{
            startTime =  Date.parse(startTime);
            endTime =  Date.parse(endTime);
            if(startTime>endTime){
                alert('开始时间不能大于结束时间')
                return;
            }
        }
        $.ajax({
            url: 'dashboard/serviceexport',
            type: 'POST',
            dataType: 'json',
            data: {'gcpaihangstart_time':startTime,'gcpaihangend_time':endTime},
            success: function (res) {

            }
        });
    }
    function gcpaihang(){
        var startTime = $('#gcpaihangstart_time').val();
        var endTime = $('#gcpaihangend_time').val();
        console.log(startTime+"___")
        console.log(endTime+"___")
        if(startTime=='' || endTime==''){
            // alert('请选择正确的查询时间')
            // return;
        }else{
            startTime =  Date.parse(startTime);
            endTime =  Date.parse(endTime);
            if(startTime>endTime){
                alert('开始时间不能大于结束时间')
                return;
            }
        }
        getConfig();
        var html='';
        $('.lyj_tbody').html(html);
        function getConfig(){
            tables_list = []
            $.ajax({
                url: 'dashboard/gcbl',
                type: 'POST',
                dataType: 'json',
                data: {'gcpaihangstart_time':startTime,'gcpaihangend_time':endTime},
                success: function (res) {
                    res.forEach(r=>{
                        tables_list.push(
                            {
                                factory_name:r.factory_name,
                                san:r.san,
                                qi:r.qi,
                            }
                        );
                    });
                    getListtbody();
                }
            });
        }
        /**
         * 物料表格
         */
        function getListtbody(){
            var html='';
            console.log(6666,tables_list);
            tables_list.forEach((r,index)=>{
                html+='<tr >';
                html+='<td style="text-align: center; vertical-align: middle; ">'+r.factory_name+'</td>';
                html+='<td style="text-align: center; vertical-align: middle; ">'+r.san+'%</td>';
                html+='<td style="text-align: center; vertical-align: middle; ">'+r.qi+'%</td>';
                html+='</tr>';
            });
            $('.lyj_tbody').html(html);
        }
    }
    document.getElementById('mySelect').addEventListener('change', function() {
        // 这里是你想要触发的操作
       // alert('选项改变了！当前选中的值是：' + this.value);
        var type = this.value;
        getConfig();
        var html='';
        $('.lyj_tbody').html(html);
        function getConfig(){
            tables_list = []
            console.log(666677,type);
            $.ajax({
                url: 'dashboard/gcbl',
                type: 'POST',
                dataType: 'json',
                data: {'type':type},
                success: function (res) {
                    res.forEach(r=>{
                        tables_list.push(
                            {
                                key:r.key,
                                factory_name:r.factory_name,
                                gcpxbl_t:r.gcpxbl_t,
                            }
                        );
                    });
                    getListtbody();
                }
            });
        }
        /**
         * 物料表格
         */
        function getListtbody(){
            var html='';
            console.log(6666,tables_list);
            tables_list.forEach((r,index)=>{
                html+='<tr >';
                html+='<td style="text-align: center; vertical-align: middle; ">'+r.key+'</td>';
                html+='<td style="text-align: center; vertical-align: middle; ">'+r.factory_name+'</td>';
                html+='<td style="text-align: center; vertical-align: middle; ">'+r.gcpxbl_t+'</td>';

                html+='</tr>';
            });
            $('.lyj_tbody').html(html);
        }
    });
</script>
